web/src/pages/[...listing].astro
510 lines · 14462 bytes
1---
2import Layout from '@layouts/Layout.astro';
3import ListingHero from '@components/things/ListingHero.astro';
4import ServiceList from '@components/things/ServiceList.astro';
5import Comments from '@components/things/Comments.svelte';
6import GitHubDetailedInfo from '@components/things/GitHubDetailedInfo.astro';
7import SecurityDetailedInfo from '@components/things/SecurityDetailedInfo.astro';
8import PrivacyPolicyDetails from '@components/things/PrivacyPolicyDetails.astro';
9import WebsiteDetailedInfo from '@components/things/WebsiteDetailedInfo.astro';
10import DockerDetailedInfo from '@components/things/DockerDetailedInfo.astro';
11import IosAppDetailedInfo from '@components/things/IosAppDetailedInfo.astro';
12import AndroidAppDetailedInfo from '@components/things/AndroidDetailedInfo.astro';
13import DiscordDetailedInfo from '@components/things/DiscordDetailedInfo.astro';
14import RedditDetailedInfo from '@components/things/RedditDetailedInfo.astro';
15import SocialShare from '@components/form/Social.astro';
16import DataActions from '@components/things/DataActions.svelte';
17import type { AwesomePrivacy, Section, Service } from '../types/Service';
18import { fetchData, slugify } from '@utils/fetch-data';
19import { fetchServiceSources } from '@utils/fetch-line-numbers';
20import { codebergUrl } from '@utils/parse-markdown';
21import { plainText, truncate } from '@utils/meta-tags';
22import { fetchChangelog } from '@utils/fetch-changelog';
23import { fetchGitHubStats } from '@utils/fetch-repo-info';
24import { fetchSecurityReport } from '@utils/fetch-security-info';
25import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy';
26import { fetchWebsiteInfo } from '@utils/fetch-website-info';
27import { fetchTrackersInfo } from '@utils/fetch-trackers-info';
28import { fetchDockerData } from '@utils/fetch-docker-instructions';
29import { fetchIosInfo } from '@utils/fetch-ios-info';
30import { fetchAndroidInfo } from '@utils/fetch-android-info';
31import { fetchPlexusInfo } from '@utils/fetch-plexus-info';
32import { fetchDiscordInfo } from '@utils/fetch-discord-info';
33import { fetchRedditInfo } from '@utils/fetch-reddit-info';
34import { site } from '@utils/config';
35import { apiBase, serviceSlug } from '@utils/api-config';
36import Button from '@components/form/Button.astro';
37
38interface Props extends Service {
39 slug: string;
40 parentSection: Section;
41 categoryName: string;
42}
43
44const {
45 name,
46 description,
47 url,
48 github,
49 codeberg,
50 git,
51 tosdrId,
52 discordInvite,
53 subreddit,
54 iosApp,
55 androidApp,
56 parentSection,
57 categoryName,
58} = Astro.props;
59
60const makeKeyWordTag = () => {
61 const keywords = [
62 `open source ${parentSection.name}`,
63 `${parentSection.name} comparison`,
64 ...(parentSection.alternativeTo || []).map(
65 (alt: string) => `${alt} alternative`,
66 ),
67 ...(parentSection.services || []).map((serv: Service) => `${serv.name} vs`),
68 'private',
69 'ad free',
70 'encrypted',
71 'open source software',
72 'privacy respecting apps',
73 'free tools',
74 ];
75 return keywords.join(', ');
76};
77
78const makePageTitle = () => {
79 return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`;
80};
81
82const makeBreadcrumbs = () => {
83 return [
84 { name: 'Home', item: '/' },
85 { name: categoryName, item: slugify(categoryName) },
86 {
87 name: parentSection.name,
88 item: `${slugify(categoryName)}/${slugify(parentSection.name)}`,
89 },
90 {
91 name: name,
92 item: `${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`,
93 },
94 ];
95};
96
97const plainDescription = plainText(description);
98
99const makeDescriptionTag = () => {
100 const summary = `${name}: ${plainDescription}`.replace(/([^.!?])$/, '$1.');
101 if (summary.length >= 120) return truncate(summary);
102 return truncate(
103 `${summary} Compare it with other private ${parentSection.name.toLowerCase()} on Awesome Privacy.`,
104 );
105};
106
107const filterServices = () => {
108 return parentSection.services.filter((s: Service) => s.name !== name);
109};
110
111export async function getStaticPaths() {
112 const pages = await fetchData().then((data) => {
113 const results: Array<Props> = [];
114 if (!data || !data.categories) return results;
115 (data as AwesomePrivacy).categories.forEach((category) => {
116 category.sections.forEach((section) => {
117 const services = (section.services || []).map((service) => {
118 return {
119 slug: `${slugify(category.name)}/${slugify(section.name)}/${slugify(service.name)}`,
120 parentSection: section,
121 categoryName: category.name,
122 ...service,
123 };
124 });
125 results.push(...services);
126 });
127 });
128 return results;
129 });
130
131 return pages.map((props: Props) => {
132 return { params: { listing: props.slug }, props };
133 });
134}
135
136const makePaginationLinks = () => {
137 const allServices = parentSection.services || [];
138 const index = allServices.findIndex((item) => item.name === name);
139 const previousItem = index > 0 ? allServices[index - 1].name : null;
140 const nextItem =
141 index < allServices.length - 1 ? allServices[index + 1].name : null;
142 return { previous: previousItem, next: nextItem };
143};
144
145const { previous, next } = makePaginationLinks();
146
147const ignoredSites = ['github.com', 'wikipedia.'];
148
149const githubData = github ? await fetchGitHubStats(github) : null;
150const securityData = github ? await fetchSecurityReport(github) : null;
151const hasSecurityData =
152 !!securityData &&
153 ((securityData.scorecard.available &&
154 securityData.scorecard.checks.length > 0) ||
155 securityData.advisories.count > 0);
156const privacyData = tosdrId ? await fetchTosdrPrivacy(tosdrId) : null;
157const iosData = iosApp ? await fetchIosInfo(iosApp) : null;
158const androidData = androidApp ? await fetchAndroidInfo(androidApp) : null;
159const plexusData = androidApp ? await fetchPlexusInfo(androidApp) : null;
160const discordData = discordInvite
161 ? await fetchDiscordInfo(discordInvite)
162 : null;
163const redditData = subreddit ? await fetchRedditInfo(subreddit) : null;
164const dockerData = await fetchDockerData(name);
165const sources = await fetchServiceSources(categoryName, parentSection.name);
166const websiteData =
167 url && !ignoredSites.some((s) => url.includes(s))
168 ? await fetchWebsiteInfo(url)
169 : null;
170const trackersData = websiteData ? await fetchTrackersInfo(url) : null;
171
172const serviceHistory = await fetchChangelog().then(({ entries }) => {
173 const isMatch = (c: { name: string; category: string; section: string }) =>
174 c.name === name &&
175 c.category === categoryName &&
176 c.section === parentSection.name;
177 const isHere = (m: {
178 name: string;
179 to: { category: string; section: string };
180 }) =>
181 m.name === name &&
182 m.to.category === categoryName &&
183 m.to.section === parentSection.name;
184 const results: Array<{
185 date: string;
186 type: 'added' | 'removed' | 'modified' | 'moved' | 'renamed';
187 fields?: string[];
188 from?: { category: string; section: string };
189 previousName?: string;
190 pr?: import('@utils/fetch-changelog').ChangelogPr | null;
191 }> = [];
192 for (const e of entries) {
193 const s = e.changes?.services;
194 const added = (s?.added || []).find(isMatch);
195 const removed = (s?.removed || []).find(isMatch);
196 const modified = (s?.modified || []).find(isMatch);
197 const moved = (s?.moved || []).find(isHere);
198 const renamed = (s?.renamed || []).find(isHere);
199 if (added) results.push({ date: e.date, type: 'added', pr: e.pr });
200 else if (removed) results.push({ date: e.date, type: 'removed', pr: e.pr });
201 else if (modified)
202 results.push({
203 date: e.date,
204 type: 'modified',
205 fields: modified.fields,
206 pr: e.pr,
207 });
208 else if (renamed)
209 results.push({
210 date: e.date,
211 type: 'renamed',
212 previousName: renamed.previousName,
213 from: renamed.from,
214 pr: e.pr,
215 });
216 else if (moved)
217 results.push({ date: e.date, type: 'moved', from: moved.from, pr: e.pr });
218 }
219 return results;
220});
221
222const findPrivacyPolicyLink = () => {
223 if (!privacyData) return null;
224 const docs = privacyData?.parameters?.documents;
225 if (docs) {
226 const pp = (docs || []).find((doc) =>
227 doc.name.toLowerCase().includes('privacy policy'),
228 );
229 if (pp) return pp.url;
230 }
231 return `https://tosdr.org/en/service/${tosdrId}`;
232};
233
234const privacyPolicyLink = findPrivacyPolicyLink();
235
236const catSlug = slugify(categoryName);
237const secSlug = slugify(parentSection.name);
238
239const getApiEndpoint = () => {
240 return `${apiBase}/v1/services/${serviceSlug(name)}`;
241};
242
243const makeSoftwareSchema = () => {
244 const operatingSystem = [
245 iosApp && 'iOS',
246 androidApp && 'Android',
247 url && 'Web',
248 ].filter(Boolean);
249 const codeRepository = github
250 ? `https://github.com/${github}`
251 : codeberg
252 ? codebergUrl(codeberg)
253 : git || null;
254 return {
255 '@context': 'https://schema.org',
256 '@type': 'SoftwareApplication',
257 name,
258 description: plainDescription || makeDescriptionTag(),
259 url,
260 applicationCategory: parentSection.name,
261 ...(operatingSystem.length && {
262 operatingSystem: operatingSystem.join(', '),
263 }),
264 ...(codeRepository && { codeRepository }),
265 };
266};
267---
268
269<Layout
270 title={makePageTitle()}
271 keywords={makeKeyWordTag()}
272 description={makeDescriptionTag()}
273 breadcrumbs={makeBreadcrumbs()}
274 customSchemaJson={makeSoftwareSchema()}
275>
276 <main>
277 <ListingHero
278 service={Astro.props}
279 parentSection={parentSection}
280 categoryName={categoryName}
281 privacyPolicyLink={privacyPolicyLink}
282 />
283 {
284 privacyData && privacyData.parameters?.points?.length > 0 && (
285 <section>
286 <h2>{name} Privacy Policy</h2>
287 <PrivacyPolicyDetails privacyData={privacyData} />
288 </section>
289 )
290 }
291 {
292 github && githubData && (
293 <section class="github-wrap">
294 <h2>{name} Source Code</h2>
295 <GitHubDetailedInfo gitHubData={githubData} repo={github} />
296 </section>
297 )
298 }
299 {
300 hasSecurityData && securityData && (
301 <section>
302 <h2>{name} Security</h2>
303 <SecurityDetailedInfo security={securityData} />
304 </section>
305 )
306 }
307 {
308 websiteData && (
309 <section>
310 <h2>{name} Website</h2>
311 <WebsiteDetailedInfo
312 url={url}
313 websiteInfo={websiteData}
314 trackers={trackersData?.trackers}
315 />
316 </section>
317 )
318 }
319 {
320 ((androidData && !androidData.error) || plexusData) && (
321 <section>
322 <h2>{name} Android App</h2>
323 <AndroidAppDetailedInfo
324 androidData={androidData}
325 plexusData={plexusData}
326 />
327 </section>
328 )
329 }
330 {
331 iosData &&
332 typeof iosData === 'object' &&
333 Object.keys(iosData).length > 0 && (
334 <section>
335 <h2>{name} iOS App</h2>
336 <IosAppDetailedInfo url={url} iosData={iosData} />
337 </section>
338 )
339 }
340 {
341 dockerData && dockerData.found && (
342 <section>
343 <h2>{name} Docker</h2>
344 <DockerDetailedInfo docker={dockerData} />
345 </section>
346 )
347 }
348 {
349 (discordData || redditData) && (
350 <section>
351 <h2>{name} Socials</h2>
352 <div class="social-wrap">
353 {discordData && <DiscordDetailedInfo discordData={discordData} />}
354 {redditData && <RedditDetailedInfo redditData={redditData} />}
355 </div>
356 </section>
357 )
358 }
359
360 <section>
361 <h2>{name} Reviews</h2>
362 <Comments client:visible />
363 </section>
364
365 <section>
366 <h2>More {parentSection.name}</h2>
367 <ServiceList
368 services={filterServices()}
369 subHeading={true}
370 noGitHubMetrics={true}
371 buttonLink={`/${catSlug}/${secSlug}/`}
372 categoryName={categoryName}
373 sectionName={parentSection.name}
374 />
375 </section>
376 <section>
377 <h2>About the Data: {name}</h2>
378 <DataActions
379 categoryName={categoryName}
380 sectionName={parentSection.name}
381 serviceName={name}
382 history={serviceHistory}
383 source={sources[name]}
384 />
385 <h3>API</h3>
386 <p>
387 You can access {name}'s data programmatically via our API. Simply make a <code
388 >GET</code
389 > request to:
390 </p>
391 <pre><a href={getApiEndpoint()}><code>{getApiEndpoint()}</code></a></pre>
392 <p>
393 The REST API is free, no-auth and CORS-enabled. To learn more, view the <a
394 href={`${apiBase}/docs`}>API Docs</a
395 > or read the <a href="/about/#api">API Usage Guide</a>.
396 </p>
397 </section>
398
399 <section>
400 <h2>Share {name}</h2>
401 <p>
402 Help your friends compare {parentSection.name}, and pick
403 privacy-respecting software and services.<br />
404 Share {name} and Awesome Privacy with your network!
405 <div>
406 <SocialShare
407 url={`${site}/${catSlug}/${secSlug}/${slugify(name)}/`}
408 title={`Checkout ${name}! \n`}
409 description={`Compare #${name} and other privacy-respecting ${parentSection.name} at ` +
410 `Awesome-Privacy.xyz, the free and open source list of private software alternatives. ` +
411 `#privacy #opensource #awesomeprivacy by @Lissy_Sykes`}
412 />
413 </div>
414 </p>
415 </section>
416
417 <div class="pagination-navigation">
418 {
419 previous ? (
420 <Button url={`/${catSlug}/${secSlug}/${slugify(previous)}/`}>
421 <span>← Previous</span>
422 <p>{previous}</p>
423 </Button>
424 ) : (
425 <p class="nothing" />
426 )
427 }
428 <a href={`/${catSlug}/${secSlug}/`} class="go-to-category">
429 View {parentSection.name} ({(parentSection.services || []).length})
430 </a>
431 {
432 next && (
433 <Button url={`/${catSlug}/${secSlug}/${slugify(next)}/`}>
434 <span>Next →</span>
435 <p>{next}</p>
436 </Button>
437 )
438 }
439 </div>
440 </main>
441</Layout>
442
443<style lang="scss">
444 main {
445 margin: var(--space-lg) auto;
446 padding: var(--space-md);
447 width: var(--width-container);
448 max-width: var(--width-container-max);
449 position: relative;
450 @media (max-width: 768px) {
451 max-width: 95%;
452 padding: var(--space-sm);
453 margin: 0 auto;
454 }
455 }
456
457 section {
458 margin: var(--space-md) 0 var(--space-2xl) 0;
459 padding: var(--space-md);
460 min-height: 8rem;
461 position: relative;
462 border: var(--border-heavy);
463 box-shadow: var(--shadow-lg);
464 background: var(--surface);
465 }
466
467 p {
468 margin: var(--space-xs) 0 var(--space-sm) 0;
469 }
470
471 h2 {
472 font-size: var(--text-3xl);
473 margin: -2rem 0 var(--space-md) -2rem;
474 box-shadow: var(--shadow-lg);
475 background: var(--accent);
476 color: var(--accent-fg);
477 width: fit-content;
478 padding: var(--space-xs) var(--space-sm);
479 @media (max-width: 768px) {
480 margin: -2rem auto var(--space-lg) auto;
481 }
482 }
483
484 h3 {
485 font-size: var(--text-lg);
486 margin-bottom: 0;
487 }
488
489 pre a {
490 text-decoration: none;
491 color: var(--foreground);
492 code {
493 background: var(--code-bg);
494 padding: 0.2rem 0.4rem;
495 border-radius: var(--curve-sm);
496 font-family: var(--font-code);
497 font-size: var(--text-sm);
498 @media (max-width: 768px) {
499 white-space: break-spaces;
500 }
501 }
502 }
503
504 .social-wrap {
505 display: flex;
506 gap: var(--space-md);
507 flex-wrap: wrap;
508 justify-content: space-between;
509 }
510</style>